package org.infodavid.common.services.validators;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.PersistenceException;

import org.infodavid.common.services.IApplicationContext;
import org.infodavid.common.services.exceptions.ServiceException;

/**
 * The Interface IValidator.
 * @param <T> the type of the object to validate
 */
public interface IValidator<T extends Serializable> {

  /**
   * Validate.
   * @param context the context
   * @param value the value
   * @throws ServiceException the service exception
   * @throws PersistenceException the persistence exception
   */
  void validate(IApplicationContext context, T value) throws ServiceException, PersistenceException;

  /**
   * Validate the data. Throw an exception on duplicated items.
   * @param context the context
   * @param values the values
   * @throws ServiceException the service exception
   * @throws PersistenceException the persistence exception
   */
  void validate(IApplicationContext context, Collection<T> values) throws ServiceException, PersistenceException;
}
